package cn.xiaomubiao.oschine.adapter.myinfo;

import android.content.Context;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;

import java.util.ArrayList;
import java.util.List;

import cn.xiaomubiao.oschine.fragment.myinfofragment.collection.MyInfoBean;

/**
 * @author
 * @version 1.0
 * @date 2017/4/2
 */

public class MyInfoBaseViewPagerAdapter extends FragmentStatePagerAdapter {
    
    private List<MyInfoBean> datas = new ArrayList<>();
    
    private Context mContext;
    
    public MyInfoBaseViewPagerAdapter(Context mContext,FragmentManager fm) {
        super(fm);
        this.mContext = mContext;
    }

    @Override
    public Fragment getItem(int position) {
        Fragment fragment = Fragment.instantiate(mContext,datas.get(position).className,datas.get(position).argument);
        return fragment;
    }

    @Override
    public int getCount() {
        return datas.size();
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return datas.get(position).title;
    }

    public void  updateData(MyInfoBean bean){
        datas.add(bean);
        notifyDataSetChanged();
    }
    public void  updateDatas(List<MyInfoBean> datas){
        this.datas.addAll(datas);
        notifyDataSetChanged();
    }
    
}
